#coding=utf-8
__author__ = 'Meteor'
import hashlib,rsa,base64

def md5(str):
    md = hashlib.md5()
    md.update(str.encode('utf-8'))
    return md.hexdigest().upper()

def md5file(file):
    md = hashlib.md5()
    with open(file,'rb') as fp:
        data = fp.read()

    md.update(data)
    return md.hexdigest()


def b64encdode(str):
    pass

def b64decode(str):
    pass


def rsakey(str,pub_key,decdoe = False ):
    if decdoe:
        return rsa.decrypt(str,pub_key)

    return rsa.encrypt(str.encode('utf-8'),pub_key)

def sha1(str):
    md = hashlib.sha1()
    md.update(str.encode('utf-8'))
    return md.hexdigest().upper()